package cn.edu.sjtu.se.metric;

public class Collector {

	private int total = 0;
	private int success = 0;
	private int connect_failure = 0;
	private int list_failure = 0;
	private int store_failure = 0;
	private int retrieve_failure = 0;
	private int delete_failure = 0;

	public synchronized void success() {
		total++;
		success++;
	}

	public synchronized void connectFail() {
		total++;
		connect_failure++;
	}

	public synchronized void listFail() {
		total++;
		list_failure++;
	}

	public synchronized void storeFail() {
		total++;
		store_failure++;
	}

	public synchronized void retrieveFail() {
		total++;
		retrieve_failure++;
	}

	public synchronized void deleteFail() {
		total++;
		delete_failure++;
	}

	public String toString() {
		return "Total\tSucc.\tCF\tLF\tSF\tRF\tDF\n" + total + '\t' + success
				+ '\t' + connect_failure + '\t' + list_failure + '\t'
				+ store_failure + '\t' + retrieve_failure + '\t'
				+ delete_failure + '\n';
	}

	public void report() {
		System.out.println(this);
	}
}
